package com.huluobo.a2208parkdemo.notice

import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import com.huluobo.a2208parkdemo.news.NewsPagingSource
import com.huluobo.a2208parkdemo.news.Repo
import com.huluobo.base.bean.NewsBeanItem
import com.huluobo.base.bean.NoticeBeanItem
import com.huluobo.base.mvvm.BaseViewModel
import com.huluobo.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

/**
 *  Created by LC on 2024/12/23.
 */
@HiltViewModel
class NoticeViewModel @Inject constructor(
    val apiService: ApiService
) : BaseViewModel() {
    fun getNewsPagingData(): Flow<PagingData<NoticeBeanItem>> {
        return Pager(
            config = PagingConfig(pageSize = 5, prefetchDistance = 5 * 5),
            pagingSourceFactory = { NoticePagingSource(apiService) }
        ).flow
    }
}